package com.csx.base.design.behavior.state;

/**
 * @author cuisongxu
 * @date 2022/10/8 12:01
 */
public class TrafficLight {

    /**
     * 交通灯的三种状态: 红灯(禁行)、黄灯(警示)、绿灯(通行)
     */
    private State state = new Red();


    public void switchToGreen() {
        state.switchToGreen(this);
    }

    public void switchToRed() {
        state.switchToRed(this);
    }

    public void switchToYellow() {
        state.switchToYellow(this);
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }
}
